<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
	$(function(){
		$(".del").click(function(){
			var id=$(this).attr("id");
			_this=$(this);
			if (confirm("确认是否删除?")) {
				
			
			$.ajax({
				url:"${pageContext.request.contextPath}/delete/"+id,
				type:"post",
				data:{_method:"DELETE"},
				success:function(data){
					_this.closest('tr').remove();
				}
				
				
			})
			
			}
		})
	});




</script>
</head>
<body>

	<h1 align="center">员工信息列表</h1>
	<table align="center" border="1px" width="70%" cellspacing="0px">
		<tr >
			<th>Id</th>
			<th>Name</th>
			<th>Email</th>
			<th>Salary</th>
			<th>DepartmentId</th>
			<th>DepartmentName</th>
			<th>option</th>

		</tr>
		<c:forEach items="${emps }" var="emp">
			<tr align="center">
				<td>${emp.id }</td>
				<td>${emp.name }</td>
				<td>${emp.email }</td>
				<td>${emp.salary }</td>
				<td>${emp.dept.id }</td>
				<td>${emp.dept.departmentName}</td>
				<td>
					<a href="update/${emp.id}">Edit</a>
					<a id=${emp.id} class="del" href="javascript:void(0)">Delete</a>
				
				
				</td>
			
			</tr>
		
	
		</c:forEach>


	</table>
	<h2 align="center"><a href="update">Add New Emps</a></h2>

</body>
</html>